1. Technical Field
The present subject matter relates to increasing code efficiency to extend battery life. More particularly, the subject matter relates to a system and method for detection of loops and capture in an instruction queue.
2. Background Information
Battery-operated systems, such as wireless devices (e.g., personal digital assistants, mobile phones), contain processors. Processors, in turn, store machine-executable code (e.g., software). A processor executes some or all portions of the machine-executable code to perform some or all of the functions of the battery-operated system. For example, in a mobile phone a processor may execute code that causes the mobile phone to play an audible ring tone or display a particular graphical image. Because battery-operated systems operate on a limited supply of power from the battery, it is desirable to increase or optimize the efficiency of code execution such that battery life is extended.
Loops are commonly used in programming for the sake of efficiency. A loop may contain syntax that reflects the beginning of the loop, such as a “for” or “while” statement. Alternatively, a non-syntactical loop may exist when a conditional branch instruction branches back to the same address a number of times, wherein the conditional branch instruction is the end of the loop, and the address targeted repeatedly is the beginning of the loop. Without a specific loop instruction, instructions in a non-syntactical loop are inefficiently fetched multiple times and stored in the instruction cache. In this way, the instruction fetch unit consumes a significant percentage of the power used by the microprocessor. Thus, it is desirable to effectively detect non-syntactical loops and handle them efficiently.